﻿using System;
using System.Data;
using System.Configuration;
using Pheonix.Fashionzoomer.DAL;
using Pheonix.Fashionzoomer.Entity.SqlServer2000;
using System.Collections.Generic;

/// <summary>
/// Summary description for StaticContentManager
/// </summary>

namespace Pheonix.Fashionzoomer.BLL
{
    public enum StaticContentType
    {
        RegistrationTerms = 1,
        HomePageVerticalAdvertisement = 2,
        LoginPageVerticalAdvertisement = 3,
        HomePageHorizontalAdvertisement = 4,
        ContactUsCMS = 5
    }

    public sealed  class StaticContentManager
    {
        private StaticContentManager() { }

        public static List<StaticContentType> GetAllContentTypes()
        {
            List<StaticContentType> result = new List<StaticContentType>();

            result.Add(StaticContentType.HomePageVerticalAdvertisement);
            result.Add(StaticContentType.HomePageHorizontalAdvertisement);
            result.Add(StaticContentType.LoginPageVerticalAdvertisement);
            result.Add(StaticContentType.RegistrationTerms);
            result.Add(StaticContentType.ContactUsCMS);

            return result;
        }

        public static string GetStaticContent(StaticContentType type)
        {
            Content content = Content.GetContentById((int)type);

            if (content != null)
                return content.ContentText;
            else
                return String.Empty;
        }

        /// <summary>
        /// This method updated a perticular static content and it is used from admin panel to update site 
        /// static contents
        /// </summary>
        /// <param name="type">Static content Id enum, indicates which staic content to update</param>
        /// <param name="contentText">The html text content to be updated</param>
        /// <returns>Returns true if update successful otherwise returns false</returns>
        public static bool UpdateStaticContent(StaticContentType type, string contentText )
        {
            Content content = new Content((int)type,contentText,DateTime.Now);

            return content.Save();
        }
    }
}
